import request from '@/utils/request'

const api = {
  storeInfo: '/notControl/storeInfo',
  clothesInviteUser: '/clothesStore/inviteUser',
  applianceInviteUser: '/applianceStore/inviteUser',
  houseInviteUser: '/houseStore/inviteUser',
  stewardRatio: '/store/stewardRatio',
  stewardGatherRatio: '/store/tuanRatio',
  storeEdit: '/store/edit',
  storeDel: '/store/delete',
  storeAdd: '/store/add',
  storePutaway: '/store/putaway',
  storeDownfall: '/store/downfall',
  clothesClerkList: '/clothesClerk/lists',
  clothesClerkAdd: '/clothesClerk/add',
  clothesClerkEdit: '/clothesClerk/edit',
  clothesClerkDel: '/clothesClerk/delete',
  houseClerkList: '/houseClerk/lists',
  houseClerkAdd: '/houseClerk/add',
  houseClerkEdit: '/houseClerk/edit',
  houseClerkDel: '/houseClerk/delete',
  applianceClerkList: '/applianceClerk/lists',
  applianceClerkAdd: '/applianceClerk/add',
  applianceClerkEdit: '/applianceClerk/edit',
  applianceClerkDel: '/applianceClerk/delete',
  storeStewardAdd: '/StoreSteward/add',
  storeClerkList: '/storeClerk/lists',
  clerkAdd: 'storeClerk/add',
  clerkDel: 'storeClerk/delete',
  clerkEdit: 'storeClerk/edit',
  clothesStoreEdit: '/clothesStore/edit',
  storeUpkeep: '/index/storeUpkeep',
  editState: '/store/editState'
}

export function storeStewardAdd (parameter) {
  return request({
    url: api.storeStewardAdd,
    method: 'post',
    data: parameter
  })
}

export function storeDownfall (parameter) {
  return request({
    url: api.storeDownfall,
    method: 'get',
    params: parameter
  })
}

export function storePutaway (parameter) {
  return request({
    url: api.storePutaway,
    method: 'get',
    params: parameter
  })
}

export function clerkEdit (parameter) {
  // const apiUrlMap = {
  //   'clothes': api.clothesClerkEdit,
  //   'house': api.houseClerkEdit,
  //   'appliance': api.applianceClerkEdit
  // }
  // const apiUrl = apiUrlMap[parameter.type]
  return request({
    url: api.clerkEdit,
    method: 'post',
    data: parameter
  })
}

export function clerkDel (parameter) {
  // const apiUrlMap = {
  //   'clothes': api.clothesClerkDel,
  //   'house': api.houseClerkDel,
  //   'appliance': api.applianceClerkDel
  // }
  // const apiUrl = apiUrlMap[parameter.type]
  return request({
    url: api.clerkDel,
    method: 'post',
    data: parameter
  })
}

export function clerkAdd (parameter) {
  // const apiUrlMap = {
  //   'clothes': api.clothesClerkAdd,
  //   'house': api.houseClerkAdd,
  //   'appliance': api.applianceClerkAdd
  // }
  // const apiUrl = apiUrlMap[parameter.type]
  return request({
    url: api.clerkAdd,
    method: 'post',
    data: parameter
  })
}

export function clerkList (parameter) {
  // const apiUrlMap = {
  //   'clothes': api.clothesClerkList,
  //   'house': api.houseClerkList,
  //   'appliance': api.applianceClerkList
  // }
  // const apiUrl = apiUrlMap[parameter.type]
  return request({
    url: api.storeClerkList,
    method: 'get',
    params: parameter
  })
}

export function houseStoreAdd (parameter) {
  return request({
    url: api.storeAdd,
    method: 'post',
    data: {
      ...parameter,
      type: 'house'
    }
  })
}

export function applianceStoreAdd (parameter) {
  return request({
    url: api.storeAdd,
    method: 'post',
    data: {
      ...parameter,
      type: 'appliance'
    }
  })
}

export function clothesStoreAdd (parameter) {
  return request({
    url: api.storeAdd,
    method: 'post',
    data: {
      ...parameter,
      type: 'clothes'
    }
  })
}

export function clothesStoreDel (parameter) {
  return request({
    url: api.storeDel,
    method: 'get',
    params: {
      ...parameter,
      type: 'clothes'
    }
  })
}

export function applianceStoreDel (parameter) {
  return request({
    url: api.storeDel,
    method: 'get',
    params: {
      ...parameter,
      type: 'appliance'
    }
  })
}

export function houseStoreDel (parameter) {
  return request({
    url: api.storeDel,
    method: 'get',
    params: {
      ...parameter,
      type: 'house'
    }
  })
}

export function houseStoreEdit (parameter) {
  return request({
    url: api.storeEdit,
    method: 'post',
    data: {
      ...parameter,
      type: 'house'
    }
  })
}

export function clothesStoreEdit (parameter) {
  return request({
    url: api.storeEdit,
    method: 'post',
    data: {
      ...parameter,
      type: 'clothes'
    }
  })
}

export function applianceStoreEdit (parameter) {
  return request({
    url: api.storeEdit,
    method: 'post',
    data: {
      ...parameter,
      type: 'appliance'
    }
  })
}

export function storeEdit (parameter) {
  return request({
    url: api.storeEdit,
    method: 'post',
    data: parameter
  })
}

export function stewardRatio (parameter) {
  return request({
    url: api.stewardRatio,
    method: 'post',
    data: parameter
  })
}

export function stewardGatherRatio (parameter) {
  return request({
    url: api.stewardGatherRatio,
    method: 'post',
    data: parameter
  })
}

export function inviteUser (parameter) {
  const apiUrlMap = {
    'clothes': api.clothesInviteUser,
    'house': api.houseInviteUser,
    'appliance': api.applianceInviteUser
  }
  const apiUrl = apiUrlMap[parameter.type]
  return request({
    url: apiUrl,
    method: 'get',
    params: parameter
  })
}

export function storeInfo (parameter) {
  return request({
    url: api.storeInfo,
    method: 'get',
    params: parameter
  })
}

export function clothesStoreEditNum (parameter) {
  return request({
    url: api.clothesStoreEdit,
    method: 'post',
    data: parameter
  })
}

export function storeUpkeep (parameter) {
  return request({
    url: api.storeUpkeep,
    method: 'post',
    data: parameter
  })
}

export function editState (parameter) {
  return request({
    url: api.editState,
    method: 'post',
    data: parameter
  })
}
